import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * 客户化管理 - service
 * @since 2019-12-18
 */
import { CPAAS_IAM } from 'utils/config';
import request from 'utils/request';
/**
 * 批量分配API
 * @async
 * @function distributeApi
 * @param {object} params - 分配参数
 */

export function distributeApi(_x) {
  return _distributeApi.apply(this, arguments);
}
/**
 * 删除客户化
 * @async
 * @function deleteBatchCustomer
 * @param {object} params - 删除项
 */

function _distributeApi() {
  _distributeApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_IAM, "/v1/tenant-custom/points/assign"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _distributeApi.apply(this, arguments);
}

export function deleteBatchCustomer(_x2) {
  return _deleteBatchCustomer.apply(this, arguments);
}
/**
 * 删除租户客户化
 * @async
 * @function deleteTenantCustomer
 * @param {object} params - 删除项
 */

function _deleteBatchCustomer() {
  _deleteBatchCustomer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    var url;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            url = "".concat(CPAAS_IAM, "/v1/tenant-custom/points");
            return _context2.abrupt("return", request(url, {
              method: 'DELETE',
              body: params
            }));

          case 2:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _deleteBatchCustomer.apply(this, arguments);
}

export function deleteTenantCustomer(_x3) {
  return _deleteTenantCustomer.apply(this, arguments);
}

function _deleteTenantCustomer() {
  _deleteTenantCustomer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(params) {
    var customPoints, url;
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            customPoints = params.customPoints;
            url = "".concat(CPAAS_IAM, "/v1/tenant-custom/points/revoke");
            return _context3.abrupt("return", request(url, {
              method: 'DELETE',
              body: customPoints
            }));

          case 3:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _deleteTenantCustomer.apply(this, arguments);
}